package com.activiti.spring.controller;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**  
 * <pre>
 * Description
 * 排他网关的默认的连线不需要条件表达式
 * Copyright:	Copyright (c)2014  
 * Company:		公司名
 * Author:		Administrator
 * Version:		1.0  
 * Created at:	2018年9月29日 下午2:57:34  
 * </pre>
 */  
@RestController
public class ExclusiveGatewayController {
	@Autowired
	private RepositoryService repositoryService;
	@Autowired
	private RuntimeService runtimeService;
	@Autowired
	private TaskService taskService;
	
	@GetMapping("getDeployExclusiveGateway")
	@ResponseBody
	public Deployment getDeployExclusiveGateway() {
		Deployment deploy = repositoryService.createDeployment().name("报销流程")
				.addClasspathResource("diagrams/ExclusiveGateway.bpmn").deploy();
		System.out.println("部署id:" + deploy.getId());
		System.out.println("部署名称：" + deploy.getName());
		return deploy;
	}
	
	@GetMapping("completeExclusiveGateway")
	@ResponseBody
	public String completeExclusiveGateway(Model model,@RequestParam("taskId") String taskId,@RequestParam("money") Integer money){
		Map<String,Object> map=new HashMap<>();
		map.put("money", money);//连线表达式
		taskService.complete(taskId,map);
		return taskId;
	}

}
